//
//  ZMyAskUntilView.m
//  DoctorFAQs
//
//  Created by zjq on 17/2/20.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "ZMyAskUntilView.h"
#import "ZConsultTableViewCell.h"
static NSString * const KZMyAskUntilIdentifier = @"KZMyAskUntilIdentifier";

@interface ZMyAskUntilView ()<UITableViewDelegate,UITableViewDataSource> {
    UITableView * _mainTabView;
}

@end
@implementation ZMyAskUntilView
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initlizeInterface];
    }
    return self;
}

- (void)initlizeInterface {
    _mainTabView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    _mainTabView.dataSource = self;
    _mainTabView.delegate = self;
    _mainTabView.rowHeight = 160*ysIZE;
    [_mainTabView registerClass:[ZConsultTableViewCell class] forCellReuseIdentifier: KZMyAskUntilIdentifier];
    [self addSubview:_mainTabView];
    [_mainTabView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    __weak typeof(self) weakSelf = self;
    ZConsultTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:KZMyAskUntilIdentifier forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.GoRescindBlock = ^() {
        [weakSelf cancelAction:indexPath.row];
    };
    
    if (indexPath.row == 0 ){
        cell.cancelBtn.hidden = NO;
    }
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (self.Undelegate && [self.Undelegate conformsToProtocol:@protocol(ZMyAskUntilViewDelegate)]) {
        [self.Undelegate selectCellWith:indexPath.row];
    }
}
- (void)cancelAction:(NSInteger )row {
    if (self.Undelegate && [self.Undelegate conformsToProtocol:@protocol(ZMyAskUntilViewDelegate)]) {
        [self.Undelegate cancelInfoWith:row];
    }
}
@end
